package phoenix.mob_android.test_objects;

import phoenix.core.PhoenixManager;
import phoenix.core.base.extensions.TestBaseMobAndroidExt;
import phoenix.core.data_models.TestUserDataModel;
import phoenix.mob_android.test_objects.data_providers.RegistrationDataProviders;

/**
 * Class contains test methods for Login from Index page
 */
public class RegistrationTests extends TestBaseMobAndroidExt
{
	public RegistrationTests(PhoenixManager p_phoenix)
	{
		super(p_phoenix);
	}

	// Data
	public RegistrationDataProviders dataProviders = new RegistrationDataProviders(manager);

	public void registrationValidationTest(String p_regEmail, String p_correct_pass, String p_email_with_space, String p_email_with_point,
			String p_email_with_dog,
			String p_email_with_two_dog, String p_email_with_dog_and_point, String p_short_pass, String p_long_pass)
	{
		try
		{
			page().indexPage().checkViewsPresence();
			page().indexPage().checkBirthday(p_regEmail);
			page().indexPage().checkInvalidEmail(p_correct_pass, p_email_with_space, p_email_with_point, p_email_with_dog, p_email_with_two_dog,
					p_email_with_dog_and_point);
			page().indexPage().checkInvalidPass(p_regEmail, p_short_pass, p_long_pass);
		}
		catch (Exception p_ex)
		{
			log().errorAndScreen("Validation registration fields test error" + p_ex.toString());
		}

		// Verifying result
		test().forErrors();
	}

	public void registrationValidationStepsTest(TestUserDataModel p_userData, String p_regEmail, String p_correct_pass, String p_email_with_space,
			String p_email_with_point,
			String p_email_with_dog, String p_email_with_two_dog, String p_email_with_dog_and_point, String p_short_pass, String p_long_pass)
	{
		try
		{
			page().indexPage()
					.checkFirstStep()
					.checkSecondStep()
					.checkThirdStep()
					.checkFourthStep(p_userData, p_regEmail, p_correct_pass, p_email_with_space, p_email_with_point, p_email_with_dog, p_email_with_two_dog,
							p_email_with_dog_and_point, p_short_pass, p_long_pass).checkFifthStep().checkSixthStep();
			page().searchPage().isOnSearchPage();
			testUser().setRegDate(cronos().getCurrentDate("yyyy-MM-dd HH:mm:ss"));
		}
		catch (Exception p_ex)
		{
			log().errorAndScreen("Validation registration fields test error" + p_ex.toString());
		}

		// Verifying result
		test().forErrors();
	}

	public void registrationTest(TestUserDataModel p_userData)
	{
		try
		{
			page().indexPage().registrationTest(p_userData.getEmail(), p_userData.getPassword());
			if (manager.isFlirt())
			{
				page().searchPage().closeMobileNumberPopUp();
			}
			page().searchPage().isOnSearchPage();
			testUser().setRegDate(cronos().getCurrentDate("yyyy-MM-dd HH:mm:ss"));
		}
		catch (Exception p_ex)
		{
			log().errorAndScreen("Registration test error" + p_ex.toString());
		}

		// Verifying result
		test().forErrors();
	}
}
